package com.bds.btcdc.web.config;

import java.util.HashSet;
import java.util.Set;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import com.bds.btcdc.web.filter.RedisSessionInterceptor;

@Configuration
public class RedisSessionConfig extends WebMvcConfigurerAdapter {

	@Override
	public void addInterceptors(InterceptorRegistry registry) {
		RedisSessionInterceptor sessionInterceptor = new RedisSessionInterceptor();
		
		Set<String> writeUrls = new HashSet<>();
		
		writeUrls.add("/ftl/login");
		writeUrls.add("/action/login/submit");
		writeUrls.add("/register/submit");

		sessionInterceptor.setWriteUrls(writeUrls);
		registry.addInterceptor(sessionInterceptor).addPathPatterns("/**");
		super.addInterceptors(registry);
	}
}
